package com.zzy.controller;

import com.zzy.model.AjaxMsg;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
@RequestMapping("/swagger/")
@Api(tags = "SwaggerController用来测试swagger注解的控制器")
//访问方式：http://localhost:8086/swagger-ui.html
public class SwaggerController {
    @ResponseBody
    @RequestMapping(value = "test")
    @ApiOperation(value="根据num获取值", notes="test: 仅1有正确返回" ,httpMethod = "get/post")
    @ApiImplicitParam(paramType="query", name = "userNumber", value = "用户编号", required = true, dataType = "Integer")
    public AjaxMsg test(@RequestParam(value = "num",required = false) Integer num){
        return AjaxMsg.returnAjaxMsg();
    }

    @ResponseBody
    @RequestMapping(value = "get",method = RequestMethod.GET)
    @ApiOperation(value="根据param获取值", notes="test: 仅1和2有正确返回" ,httpMethod = "get")
    @ApiImplicitParam(paramType="String", name = "param", value = "String参数名字", required = false, dataType = "param")
    public AjaxMsg getSwaggerUi(@RequestParam(value = "param",required = false) String param){
        return AjaxMsg.returnAjaxMsg();
    }

}
